package com.leqicheng.tenon.pay.alipay;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;

import com.leqicheng.tenon.login.PopWindow;
import com.leqicheng.tenon.pay.PayInfoModel;
import com.leqicheng.tenon.util.HttpRequest;
import com.leqicheng.tenon.util.RequestTypeEnum;

public class ChargeAliPayHttpRequest extends HttpRequest {
    private final Context mContext;

    public ChargeAliPayHttpRequest(Context context, PopWindow popWindow) {
        super(context, popWindow);
        this.mContext = context;
    }

    public String postRequest(PayInfoModel model, boolean isEgretGame) {
        Map<String, String> Data = new HashMap<String, String>();
        RequestTypeEnum requestType = RequestTypeEnum.CHARGE_ALIPAY;
        Data.put("user_id", model.getTenonUserId());
        Data.put("channel_key", model.getChannelId());
        Data.put("game_key", model.getGameId());
        Data.put("sign", model.getPaySign());
        String requestUriType = "ali-pay";
        if (!isEgretGame) {
            Data.put("price", model.getPayPrice());
            Data.put("name", model.getPayName());
            Data.put("orderid", model.getPayOrderId());
            Data.put("description", model.getPayDescription());
            Data.put("notify_url", model.getPayNotifyUrl());
            Data.put("timestamp", model.getPayTimeStamp());
        } else {
            requestUriType = "egret-ali-pay";
            Data.put("egret_game_id", model.getEgretGameId());
            Data.put("goods_id", model.getEgretGoodsId());
            Data.put("egret_order_id", model.getEgretOrderId());
            Data.put("ext", model.getEgretExt());
            Data.put("time", model.getEgretTime());
            Data.put("money", model.getPayPrice());
            Data.put("goods_name", model.getPayName());
        }
        this.AsyncHttpClientPostOnBack(requestType, Data, requestUriType);
        return requestUriType;
    }
}
